home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / STATUSBA.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  201 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.9  $
  6. //
  7. // Definition of class TStatusBar.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_STATUSBA_H)
  10. #define OWL_STATUSBA_H
  11.  
  12. #if !defined(OWL_MESSAGEB_H)
  13. # include <owl/messageb.h>
  14. #endif
  15. #if !defined(OWL_TEXTGADG_H)
  16. # include <owl/textgadg.h>
  17. #endif
  18.  
  19. #if defined(BI_NAMESPACE)
  20. namespace OWL {
  21. #endif
  22.  
  23. // Generic definitions/compiler options (eg. alignment) preceeding the 
  24. // definition of classes
  25. #include <services/preclass.h>
  26.  
  27. //
  28. // class TStatusBar
  29. // ~~~~~ ~~~~~~~~~~
  30. // Status bars have more options than a plain message bar: you can have
  31. // multiple text gadgets, different style borders, and you can reserve space
  32. // for mode indicators
  33. //
  34. class _OWLCLASS TStatusBar : public TMessageBar {
  35.   public:
  36.     enum TModeIndicator {
  37.       ExtendSelection = 1,
  38.       CapsLock        = 1 << 1,
  39.       NumLock         = 1 << 2,
  40.       ScrollLock      = 1 << 3,
  41.       Overtype        = 1 << 4,
  42.       RecordingMacro  = 1 << 5,
  43.       SizeGrip        = 1 << 6
  44.     };
  45.  
  46.     TStatusBar(TWindow*              parent = 0,
  47.                TGadget::TBorderStyle borderStyle = TGadget::Recessed,
  48.                uint                  modeIndicators = 0,
  49.                TFont*                font = 0, //new TGadgetWindowFont(6),
  50.                TModule*              module = 0);
  51.  
  52.     // By default, adds "gadget" after the existing text gadgets and before
  53.     // the mode indicator gadgets. Sets the border style to the style specified
  54.     // during construction.
  55.     //
  56.     void        Insert(TGadget& gadget, TPlacement = After, TGadget* sibling = 0);
  57.  
  58.     // Overriden method of TMessageBar to use our own text gadget
  59.     // Set (or clear if 0) menu/command item hint text displayed in/on bar
  60.     //
  61.     virtual void    SetHintText(const char* text);
  62.  
  63.     // In order for the mode indicator status to appear you must have
  64.     // specified the mode when the window was constructed
  65.     //
  66.     bool        GetModeIndicator(TModeIndicator i) const;
  67.     void        SetModeIndicator(TModeIndicator, bool state);
  68.     void        ToggleModeIndicator(TModeIndicator);
  69.  
  70.     struct TSpacing {
  71.       TMargins::TUnits  Units;
  72.       int               Value;
  73.       TSpacing();
  74.     };
  75.  
  76.     // Sets the spacing to be used between mode indicator gadgets
  77.     //
  78.     void        SetSpacing(const TSpacing& spacing);
  79.  
  80.     // Control whether hint text is display over the whole window or in
  81.     // a text gadget.
  82.     //
  83.     void        SetWideHints(bool on);
  84.  
  85.   protected:
  86.     void        PositionGadget(TGadget* previous, TGadget* next, TPoint& point);
  87.     TSpacing&   GetSpacing();
  88.  
  89.     uint        GetNumModeIndicators();
  90.     uint        GetModeIndicators() const;
  91.     void        SetModeIndicators(uint modeindicators);
  92.  
  93.  
  94.     void        EvOwlFrameSize(uint sizeType, TSize&);
  95.     uint        EvNCHitTest(TPoint& point);
  96.  
  97.   protected_data:
  98.     TGadget::TBorderStyle  BorderStyle;
  99.     TSpacing               Spacing;
  100.     uint                   NumModeIndicators;
  101.     uint                   ModeIndicators;
  102.     uint                   ModeIndicatorState;
  103.     bool                   WideHintText;
  104.  
  105.   private:
  106.     bool        GetGadgetAndStrings(TModeIndicator mode, TTextGadget*& gadget,
  107.                                     const char*& strOn);
  108.     bool        IsModeIndicator(TGadget* gadget);
  109.  
  110. #if !defined(BI_PLAT_WIN16)
  111.     void        InsertSizeGrip(void);
  112. #endif
  113.  
  114.     // Hidden to prevent accidental copying or assignment
  115.     //
  116.     TStatusBar(const TStatusBar&);
  117.     TStatusBar& operator =(const TStatusBar&);
  118.  
  119.   DECLARE_CASTABLE;
  120.  
  121. #if !defined(BI_PLAT_WIN16)
  122.   // The event handlers are for managing size grips, which 
  123.   // aren't available in 16-bit Windows
  124.   //
  125.   DECLARE_RESPONSE_TABLE(TStatusBar);
  126. #endif
  127. };
  128.  
  129. // Generic definitions/compiler options (eg. alignment) following the 
  130. // definition of classes
  131. #include <services/posclass.h>
  132.  
  133. #if defined(BI_NAMESPACE)
  134. } // namespace OWL
  135. #endif
  136.  
  137. //----------------------------------------------------------------------------
  138. // Inline implementations
  139. //
  140. //
  141.  
  142. //
  143. // Return true if the mode indicator is on.
  144. //
  145. inline bool TStatusBar::GetModeIndicator(TStatusBar::TModeIndicator i) const {
  146.   return (ModeIndicatorState & i) ? 1 : 0;
  147. }
  148.  
  149. //
  150. // Initialize spacing.
  151. //
  152. inline TStatusBar::TSpacing::TSpacing() {
  153.   Units = TMargins::LayoutUnits;
  154.   Value = 0;
  155. }
  156.  
  157. //
  158. // Set the spacing between the mode indicator gadgets.
  159. //
  160. inline void TStatusBar::SetSpacing(const TStatusBar::TSpacing& spacing) {
  161.   Spacing = spacing;
  162. }
  163.  
  164. //
  165. // Return the spacing between the mode indicator gadgets.
  166. //
  167. inline TStatusBar::TSpacing& TStatusBar::GetSpacing() {
  168.   return Spacing;
  169. }
  170.  
  171. //
  172. // Return number of mode indicators on.
  173. //
  174. inline uint TStatusBar::GetNumModeIndicators() {
  175.   return NumModeIndicators;
  176. }
  177.  
  178. //
  179. // Return the bit flags for which indicator is on.
  180. //
  181. inline uint TStatusBar::GetModeIndicators() const {
  182.   return ModeIndicators;
  183. }
  184.  
  185. //
  186. // Set the bit flags for which indicator is on.
  187. //
  188. inline void TStatusBar::SetModeIndicators(uint modeindicators) {
  189.   ModeIndicators = modeindicators;
  190. }
  191.  
  192. //
  193. // Informs the StatusBar whether hints should be displayed in a text gadget
  194. // (on == false) or over the area of the whole statusbar (on == true).
  195. //
  196. inline void TStatusBar::SetWideHints(bool on) {
  197.   WideHintText = on;
  198. }
  199.  
  200. #endif  // OWL_STATUSBA_H
  201.